package com.ruoyi.tj.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;


@Configuration
public class WebConfiguration {



//    @Bean
//    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(){
//        MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
//        ObjectMapper mapper = mappingJackson2HttpMessageConverter.getObjectMapper();
//        mapper.setSerializerFactory(mapper.getSerializerFactory().withSerializerModifier(new MyBeanSerializerModifier()));
//        mappingJackson2HttpMessageConverter.setObjectMapper(mapper);
//        return mappingJackson2HttpMessageConverter;
//    }

    @Bean
    public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
        ObjectMapper objectMapper = builder.createXmlMapper(false).build();
        SimpleModule module = new SimpleModule();
         module.addSerializer(Boolean.class, new NumericBooleanSerializer());
        // module.addDeserializer()
        objectMapper.registerModule(module);
        return objectMapper;
    }

}
